<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="Content-Type" content="text/html;" charset="<?php echo CHARSET;?>">
<title>本地生活</title>
<link href="/Public/admin/css/skin_0.css" rel="stylesheet" type="text/css" id="cssfile"/>
<script type="text/javascript" src="/Public/static/jquery.js"></script>
<script type="text/javascript" src="/Public/static/jquery.validation.min.js"></script>
<script type="text/javascript" src="/Public/admin/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Public/admin/js/admincp.js"></script>
<script type="text/javascript" src="/Public/admin/js/jquery.tooltip.js"></script>
<script language="javascript">
var SiteUrl = '<?php echo (C("SiteUrl")); ?>';
var AdminUrl = SiteUrl+'/<?php echo (MODULE_NAME); ?>';
</script>
</head><body>
<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <h3>权限管理</h3>
      <ul class="tab-base">
        <li><a href="<?php echo U('Setting/auth_list');?>"><span>管理</span></a></li>
        <li><a href="JavaScript:void(0);" class="current"><span>编辑</span></a></li>
      </ul>
    </div>
  </div>
  <div class="fixed-empty"></div>
  <form id="add_form" method="post" action="<?php echo U('Setting/auth_list',array('op'=>'edit'));?>">
    <table class="table tb-type2 nobdb">
      <tbody>
        <tr class="noborder">
          <td colspan="2" class="required"><label class="validation" for="a_title">权限标题:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" id="a_title" name="a_title" value="<?php echo ($vo['a_title']); ?>" class="txt"></td>
          <td class="vatop tips"></td>
        </tr>      
        <tr class="noborder">
          <td colspan="2" class="required"><label class="validation" for="a_name">权限名称:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" id="a_name" name="a_name" value="<?php echo ($vo['a_name']); ?>" class="txt"></td>
          <td class="vatop tips">格式为：控制器-方法 OR ：控制器-*</td>
        </tr>
         <tr class="noborder">
          <td colspan="2" class="required"><label class="validation" for="a_sort">排序:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" id="a_sort" name="a_sort" value="<?php echo ($vo['a_sort']); ?>" class="txt"></td>
          <td class="vatop tips"></td>
        </tr>       
      </tbody>
      <tfoot>
        <tr class="tfoot">
          <td colspan="2">
          	<input type='hidden' name='a_id' value="<?php echo ($vo['a_id']); ?>">
          	<a href="JavaScript:void(0);" class="btn" id="submitBtn"><span>保存</span></a>
          </td>
        </tr>
      </tfoot>
    </table>
  </form>
</div>
<script>
//按钮先执行验证再提交表
$(function(){$("#submitBtn").click(function(){
    if($("#add_form").valid()){
     $("#add_form").submit();
	}
	});
});
$(document).ready(function(){
	$("#add_form").validate({
		errorPlacement: function(error, element){
			error.appendTo(element.parent().parent().prev().find('td:first'));
        },
        success: function(label){
            label.addClass('valid');
        },
        rules : {
			a_title : {
			 	required : true,	
			},			
            a_name : {
                required : true,
				remote	: {
                    url : AdminUrl+'?c=Setting&a=check_auth_name',
                    type:'get',
                    data:{
						a_id : <?php echo $vo['a_id'];?>,
                    	a_name : function(){
                            return $('#a_name').val();
                        }
                    }
                }
            }		
        },
        messages : {
			a_title : {
			 	required : '请输入标题',	
			},				
            a_name : {
                required : '请输入权限名称',
				remote	 : '此名称已存在'
            }
        }
	});
});
</script> 
</body></html>